From c011b268196b8356c70f668506a1133086bc9477 Mon Sep 17 00:00:00 2001 From: Justin Burkett Date: Mon, 19 Oct 2020 11:15:35 -0400 Subject: [PATCH] Add tests for keymap-based-bindings --- which-key-tests.el | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/which-key-tests.el b/which-key-tests.el index f9fac65c73b..1611d51cc04 100644 --- a/which-key-tests.el +++ b/which-key-tests.el @@ -27,7 +27,24 @@ (require 'which-key) (require 'ert) -(ert-deftest which-key-test-prefix-declaration () +(ert-deftest which-key-test--keymap-based-bindings () + (let ((map (make-sparse-keymap)) + (emacs-lisp-mode-map (copy-keymap emacs-lisp-mode-map))) + (emacs-lisp-mode) + (define-key map "x" 'ignore) + (define-key emacs-lisp-mode-map "\C-c\C-a" 'complete) + (define-key emacs-lisp-mode-map "\C-c\C-b" map) + (which-key-add-keymap-based-replacements emacs-lisp-mode-map + "C-c C-a" '("mycomplete" . complete) + "C-c C-b" "mymap") + (should (equal + (which-key--maybe-replace '("C-c C-a" . "complete")) + '("C-c C-a" . "mycomplete"))) + (should (equal + (which-key--maybe-replace '("C-c C-b" . "")) + '("C-c C-b" . "mymap"))))) + +(ert-deftest which-key-test--prefix-declaration () "Test `which-key-declare-prefixes' and `which-key-declare-prefixes-for-mode'. See Bug #109." (let* ((major-mode 'test-mode) -- 2.30.2